<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html-el" %>
<%@ taglib prefix="portal" uri="http://amc.af.mil/portal-el" %>
<%@ taglib prefix="rad" uri="http://amc.af.mil/radtaglibrary" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="display" uri="http://displaytag.sf.net" %>
<html>
<head>
    <title>Edit DRMO Package</title>
</head>

<body>
<div id="portal-left-bar">
    <jsp:include page="../navigation/navigationMenu.jsp"/>
</div>

<rad:useBean id="drmoPackageViewHelper" beanName="drmoPackageViewHelper"/>
<c:set var="drmoPackage" value="${drmoPackageViewHelper.package}"/>
<c:set var="itemsList" value="${drmoPackageViewHelper.package.identifiedItemsList}"/>

<rad:useBean id="equipmentTypeViewHelper"/>

<div id="portal-content">
    <portal:box title="Edit Drmo Package" style="width: 800px">
        <portal:subSection title="Package Details">
            <div id="createDrmoPackage">
                <html:form action="drmo/editPackage.do" method="post">
                    <html:hidden property="packageId" value="${drmoPackage.id}"/>
                    <p><label for="dtid">DTID</label>
                        <html:text property="dtid" disabled="true" value="${drmoPackage.dtid}"/>
                    </p>

                    <p>
                        <label for="statusId">Package Status</label>
                        <c:choose>
                            <c:when test="${drmoPackage.turninDate ne null}">
                                <html:select property="statusId" styleId="statusId" disabled="true">
                                    <html:option value="1">Pending</html:option>
                                    <html:option value="2">Complete</html:option>
                                </html:select>
                            </c:when>
                            <c:otherwise>
                                <html:select property="statusId" styleId="statusId">
                                    <html:option value="1">Pending</html:option>
                                    <html:option value="2">Complete</html:option>
                                </html:select>
                            </c:otherwise>
                        </c:choose>

                    </p>

                    <p>
                        <p><label for="itemTypeId">Item Type</label>
                            <html:select property="itemTypeId" styleId="itemTypeId"
                                         value="${itemsList[0].equipmentType.id}"
                                         disabled="true">
                                <html:option value="-1">Please Select An Equipment Type</html:option>
                                <html:optionsCollection name="equipmentTypeViewHelper"
                                                        property="all"
                                                        value="id"
                                                        label="name"/>
                            </html:select></p>
                    </p>

                    <p><label for="search">Serial</label>
                        <html:text property="search" style="search" styleId="search"/>
                    </p>

                    <p><html:button property="dummy" value="Add To List"
                                    onclick="javascript:addDrmoPackageItemBySerial();"/></p>
                    <%--<p><html:button property="dummy" value="Add To List" onclick="javascript:addDrmoPackageItem();"/></p>--%>
                    <div id="searchStatus"></div>

                    <p>&nbsp;</p>
                    <display:table htmlId="content"
                                   name="drmoPackageViewHelper.package.identifiedItems"
                                   decorator="mil.af.amc.adpetracker.web.decorators.DrmoPackageDecorator"
                                   defaultsort="1"
                                   style="width: 100%"
                                   id="item">
                        <display:column title="Serial">
                            <html:link href="viewEquipmentItem.do?itemId=${item.id}"><c:out value="${item.serial}"/>
                            </html:link>

                        </display:column>
                        <display:column title="Manufacturer">
                            <c:out value="${item.itemModel.manufacturer.name}"/>
                        </display:column>
                        <display:column title="Description">
                            <c:out value="${item.description}"/>
                        </display:column>
                        <display:column title="Actions">
                            <html:hidden property="itemId" styleId="itemId" value="${item.id}"/>
                            <html:button property="dummy" value="Remove"
                                         onclick="javascript:Element.remove(document.getElementById('${item.id}-row'));"/>
                        </display:column>
                    </display:table>

                    <p><html:submit value="Update Package"/></p>

                </html:form>
            </div>
        </portal:subSection>
    </portal:box>
</div>

</body>
</html>